package cn.inyaa.admin.blog.controller;

import cn.inyaa.admin.blog.bean.InyaaTag;
import cn.inyaa.admin.blog.service.InyaaTagService;
import com.inyaa.base.bean.BaseResult;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/tag")
@RequiredArgsConstructor
public class InyaaTagController {

    private final InyaaTagService inyaaTagService;

    @PostMapping("/save")
    public BaseResult<String> save(@RequestBody InyaaTag tag) {
        inyaaTagService.save(tag);
        return BaseResult.success();
    }

    @GetMapping("/list")
    public BaseResult<List<InyaaTag>> list() {
        return BaseResult.success(inyaaTagService.findAll());
    }

    @PostMapping("/delete")
    public BaseResult<String> delete(@RequestBody InyaaTag tag) {
        inyaaTagService.delete(tag);
        return BaseResult.success();
    }
}
